<template>
    <div>
        <el-input type="textarea" v-model="con" :rows="8"  placeholder="请填写取消农事原因，便于负责人知晓以及对计划优化"/>
        <div style="margin: 20px 0 0 0;">
            <el-button size="small" type="primary" @click="confirm">确 定</el-button>
            <el-button size="small" @click="close">取 消</el-button>
        </div>
    </div>
</template>
<script setup>
import {ref,onMounted} from "vue"
import { message } from '@/utils/element'
import {cancelPlantLineItem} from '@/api/plant'
import { emitter } from '@/utils/bus.js'
const props = defineProps({
    options:{
        type:Object,
        default:{}
    }
})

const emit = defineEmits(['close'])

const con = ref('')

onMounted(()=>{
    
})

const confirm = async ()=>{
   // props.options.taskStatus = 'CANCEL' // 状态设为取消状态
   // props.options.reason = con.value
    if(!con.value){
        return message("请填写取消农事原因！",3)
    }
    const res = await cancelPlantLineItem({
        "plantLineId": props.options.plantLineId,
        "reason": con.value,
        "taskStatus": "CANCEL",
    })
    if(res.code ==0 || res.success){
        message('数据提交成功',2)
        close()
        emitter.emit('reload') // 刷新页面
    }else{
        message(res.message,3)
    }
}

const close=()=>{
    emit('close') 
}
</script>